import pandas as pd
import matplotlib.pyplot as plt
from matplotlib import style
style.use('ggplot')
%matplotlib inline
import plotly
import plotly.express as px
import plotly.graph_objects as go
plt.rcParams['figure.figsize']=17,8
import cufflinks as cf
from plotly.offline import init_notebook_mode,plot,iplot
df=pd.read_csv(r"C:\Users\Himangshu Nayak\Desktop\Python project\COVID DATA.csv")
df
| Name of States / UT | Confirmed cases | Cured/Discharged/Migrated | Death | Date | |
|---|---|---|---|---|---|
| 0 | Andaman and Nicobar Islands | 7675 | 7541 | 129 | 19-11-2021 |
| 1 | Andhra Pradesh | 2070738 | 2053755 | 14423 | 19-11-2021 |
| 2 | Arunachal Pradesh | 55242 | 54908 | 280 | 19-11-2021 |
| 3 | Assam | 614863 | 605656 | 6065 | 19-11-2021 |
| 4 | Bihar | 726178 | 716476 | 9663 | 19-11-2021 |
| 5 | Chandigarh | 65394 | 64546 | 820 | 19-11-2021 |
| 6 | Chhattisgarh | 1006459 | 992596 | 13591 | 19-11-2021 |
| 7 | Dadar Nagar Haveli | 10682 | 10678 | 4 | 19-11-2021 |
| 8 | Delhi | 1440575 | 1415118 | 25095 | 19-11-2021 |
| 9 | Goa | 178594 | 174965 | 3377 | 19-11-2021 |
| 10 | Gujarat | 827112 | 816710 | 10090 | 19-11-2021 |
| 11 | Haryana | 771495 | 761307 | 10052 | 19-11-2021 |
| 12 | Himachal Pradesh | 226213 | 221243 | 3826 | 19-11-2021 |
| 13 | Jammu and Kashmir | 334823 | 328783 | 4459 | 19-11-2021 |
| 14 | Jharkhand | 349089 | 343812 | 5139 | 19-11-2021 |
| 15 | Karnataka | 2992897 | 2947354 | 38165 | 19-11-2021 |
| 16 | Kerala | 5084095 | 4984328 | 36847 | 19-11-2021 |
| 17 | Ladakh | 21270 | 20847 | 212 | 19-11-2021 |
| 18 | Madhya Pradesh | 792993 | 782390 | 10525 | 19-11-2021 |
| 19 | Maharashtra | 6627838 | 6471763 | 140692 | 19-11-2021 |
| 20 | Manipur | 124700 | 122160 | 1956 | 19-11-2021 |
| 21 | Meghalaya | 84150 | 82412 | 1467 | 19-11-2021 |
| 22 | Mizoram | 130912 | 125170 | 473 | 19-11-2021 |
| 23 | Nagaland | 32032 | 31206 | 695 | 19-11-2021 |
| 24 | Odisha | 1046317 | 1035613 | 8386 | 19-11-2021 |
| 25 | Puducherry | 128561 | 126368 | 1867 | 19-11-2021 |
| 26 | Punjab | 602906 | 586021 | 16577 | 19-11-2021 |
| 27 | Rajasthan | 954568 | 945518 | 8954 | 19-11-2021 |
| 28 | Sikkim | 32129 | 31621 | 402 | 19-11-2021 |
| 29 | Tamil Nadu | 2717978 | 2672564 | 36336 | 19-11-2021 |
| 30 | Telengana | 674181 | 666509 | 3978 | 19-11-2021 |
| 31 | Tripura | 84698 | 83793 | 818 | 19-11-2021 |
| 32 | Uttarakhand | 344074 | 336491 | 7404 | 19-11-2021 |
| 33 | Uttar Pradesh | 1710306 | 1687296 | 22909 | 19-11-2021 |
| 34 | West Bengal | 1607516 | 1580089 | 19355 | 19-11-2021 |
df['Active_cases']=df['Confirmed cases']-(df['Cured/Discharged/Migrated']+df['Death'])
df
| Name of States / UT | Confirmed cases | Cured/Discharged/Migrated | Death | Date | Active_cases | |
|---|---|---|---|---|---|---|
| 0 | Andaman and Nicobar Islands | 7675 | 7541 | 129 | 19-11-2021 | 5 |
| 1 | Andhra Pradesh | 2070738 | 2053755 | 14423 | 19-11-2021 | 2560 |
| 2 | Arunachal Pradesh | 55242 | 54908 | 280 | 19-11-2021 | 54 |
| 3 | Assam | 614863 | 605656 | 6065 | 19-11-2021 | 3142 |
| 4 | Bihar | 726178 | 716476 | 9663 | 19-11-2021 | 39 |
| 5 | Chandigarh | 65394 | 64546 | 820 | 19-11-2021 | 28 |
| 6 | Chhattisgarh | 1006459 | 992596 | 13591 | 19-11-2021 | 272 |
| 7 | Dadar Nagar Haveli | 10682 | 10678 | 4 | 19-11-2021 | 0 |
| 8 | Delhi | 1440575 | 1415118 | 25095 | 19-11-2021 | 362 |
| 9 | Goa | 178594 | 174965 | 3377 | 19-11-2021 | 252 |
| 10 | Gujarat | 827112 | 816710 | 10090 | 19-11-2021 | 312 |
| 11 | Haryana | 771495 | 761307 | 10052 | 19-11-2021 | 136 |
| 12 | Himachal Pradesh | 226213 | 221243 | 3826 | 19-11-2021 | 1144 |
| 13 | Jammu and Kashmir | 334823 | 328783 | 4459 | 19-11-2021 | 1581 |
| 14 | Jharkhand | 349089 | 343812 | 5139 | 19-11-2021 | 138 |
| 15 | Karnataka | 2992897 | 2947354 | 38165 | 19-11-2021 | 7378 |
| 16 | Kerala | 5084095 | 4984328 | 36847 | 19-11-2021 | 62920 |
| 17 | Ladakh | 21270 | 20847 | 212 | 19-11-2021 | 211 |
| 18 | Madhya Pradesh | 792993 | 782390 | 10525 | 19-11-2021 | 78 |
| 19 | Maharashtra | 6627838 | 6471763 | 140692 | 19-11-2021 | 15383 |
| 20 | Manipur | 124700 | 122160 | 1956 | 19-11-2021 | 584 |
| 21 | Meghalaya | 84150 | 82412 | 1467 | 19-11-2021 | 271 |
| 22 | Mizoram | 130912 | 125170 | 473 | 19-11-2021 | 5269 |
| 23 | Nagaland | 32032 | 31206 | 695 | 19-11-2021 | 131 |
| 24 | Odisha | 1046317 | 1035613 | 8386 | 19-11-2021 | 2318 |
| 25 | Puducherry | 128561 | 126368 | 1867 | 19-11-2021 | 326 |
| 26 | Punjab | 602906 | 586021 | 16577 | 19-11-2021 | 308 |
| 27 | Rajasthan | 954568 | 945518 | 8954 | 19-11-2021 | 96 |
| 28 | Sikkim | 32129 | 31621 | 402 | 19-11-2021 | 106 |
| 29 | Tamil Nadu | 2717978 | 2672564 | 36336 | 19-11-2021 | 9078 |
| 30 | Telengana | 674181 | 666509 | 3978 | 19-11-2021 | 3694 |
| 31 | Tripura | 84698 | 83793 | 818 | 19-11-2021 | 87 |
| 32 | Uttarakhand | 344074 | 336491 | 7404 | 19-11-2021 | 179 |
| 33 | Uttar Pradesh | 1710306 | 1687296 | 22909 | 19-11-2021 | 101 |
| 34 | West Bengal | 1607516 | 1580089 | 19355 | 19-11-2021 | 8072 |
df.style.background_gradient(cmap='Greens')
| Name of States / UT | Confirmed cases | Cured/Discharged/Migrated | Death | Date | Active_cases | |
|---|---|---|---|---|---|---|
| 0 | Andaman and Nicobar Islands | 7675 | 7541 | 129 | 19-11-2021 | 5 |
| 1 | Andhra Pradesh | 2070738 | 2053755 | 14423 | 19-11-2021 | 2560 |
| 2 | Arunachal Pradesh | 55242 | 54908 | 280 | 19-11-2021 | 54 |
| 3 | Assam | 614863 | 605656 | 6065 | 19-11-2021 | 3142 |
| 4 | Bihar | 726178 | 716476 | 9663 | 19-11-2021 | 39 |
| 5 | Chandigarh | 65394 | 64546 | 820 | 19-11-2021 | 28 |
| 6 | Chhattisgarh | 1006459 | 992596 | 13591 | 19-11-2021 | 272 |
| 7 | Dadar Nagar Haveli | 10682 | 10678 | 4 | 19-11-2021 | 0 |
| 8 | Delhi | 1440575 | 1415118 | 25095 | 19-11-2021 | 362 |
| 9 | Goa | 178594 | 174965 | 3377 | 19-11-2021 | 252 |
| 10 | Gujarat | 827112 | 816710 | 10090 | 19-11-2021 | 312 |
| 11 | Haryana | 771495 | 761307 | 10052 | 19-11-2021 | 136 |
| 12 | Himachal Pradesh | 226213 | 221243 | 3826 | 19-11-2021 | 1144 |
| 13 | Jammu and Kashmir | 334823 | 328783 | 4459 | 19-11-2021 | 1581 |
| 14 | Jharkhand | 349089 | 343812 | 5139 | 19-11-2021 | 138 |
| 15 | Karnataka | 2992897 | 2947354 | 38165 | 19-11-2021 | 7378 |
| 16 | Kerala | 5084095 | 4984328 | 36847 | 19-11-2021 | 62920 |
| 17 | Ladakh | 21270 | 20847 | 212 | 19-11-2021 | 211 |
| 18 | Madhya Pradesh | 792993 | 782390 | 10525 | 19-11-2021 | 78 |
| 19 | Maharashtra | 6627838 | 6471763 | 140692 | 19-11-2021 | 15383 |
| 20 | Manipur | 124700 | 122160 | 1956 | 19-11-2021 | 584 |
| 21 | Meghalaya | 84150 | 82412 | 1467 | 19-11-2021 | 271 |
| 22 | Mizoram | 130912 | 125170 | 473 | 19-11-2021 | 5269 |
| 23 | Nagaland | 32032 | 31206 | 695 | 19-11-2021 | 131 |
| 24 | Odisha | 1046317 | 1035613 | 8386 | 19-11-2021 | 2318 |
| 25 | Puducherry | 128561 | 126368 | 1867 | 19-11-2021 | 326 |
| 26 | Punjab | 602906 | 586021 | 16577 | 19-11-2021 | 308 |
| 27 | Rajasthan | 954568 | 945518 | 8954 | 19-11-2021 | 96 |
| 28 | Sikkim | 32129 | 31621 | 402 | 19-11-2021 | 106 |
| 29 | Tamil Nadu | 2717978 | 2672564 | 36336 | 19-11-2021 | 9078 |
| 30 | Telengana | 674181 | 666509 | 3978 | 19-11-2021 | 3694 |
| 31 | Tripura | 84698 | 83793 | 818 | 19-11-2021 | 87 |
| 32 | Uttarakhand | 344074 | 336491 | 7404 | 19-11-2021 | 179 |
| 33 | Uttar Pradesh | 1710306 | 1687296 | 22909 | 19-11-2021 | 101 |
| 34 | West Bengal | 1607516 | 1580089 | 19355 | 19-11-2021 | 8072 |
Active_cases=df.groupby('Name of States / UT')['Active_cases'].sum().sort_values(ascending=False).to_frame()
Active_cases.style.background_gradient(cmap='Greens')
| Active_cases | |
|---|---|
| Name of States / UT | |
| Kerala | 62920 |
| Maharashtra | 15383 |
| Tamil Nadu | 9078 |
| West Bengal | 8072 |
| Karnataka | 7378 |
| Mizoram | 5269 |
| Telengana | 3694 |
| Assam | 3142 |
| Andhra Pradesh | 2560 |
| Odisha | 2318 |
| Jammu and Kashmir | 1581 |
| Himachal Pradesh | 1144 |
| Manipur | 584 |
| Delhi | 362 |
| Puducherry | 326 |
| Gujarat | 312 |
| Punjab | 308 |
| Chhattisgarh | 272 |
| Meghalaya | 271 |
| Goa | 252 |
| Ladakh | 211 |
| Uttarakhand | 179 |
| Jharkhand | 138 |
| Haryana | 136 |
| Nagaland | 131 |
| Sikkim | 106 |
| Uttar Pradesh | 101 |
| Rajasthan | 96 |
| Tripura | 87 |
| Madhya Pradesh | 78 |
| Arunachal Pradesh | 54 |
| Bihar | 39 |
| Chandigarh | 28 |
| Andaman and Nicobar Islands | 5 |
| Dadar Nagar Haveli | 0 |
df.plot(kind='bar',x='Name of States / UT',y='Confirmed cases')
<AxesSubplot:xlabel='Name of States / UT'>
fig=plt.figure(figsize=(20,10),dpi=200)
axes=fig.add_axes([0,0,1,1])
axes.bar(df['Name of States / UT'],df['Confirmed cases'])
axes.set_title("Total Cases in India")
axes.set_xlabel("Name of States / UT")
axes.set_ylabel("Confirmed cases")
plt.show()
plt.bar(df['Name of States / UT'],df['Confirmed cases'])
<BarContainer object of 35 artists>
px.bar(df,x='Name of States / UT',y='Confirmed cases')
plt.scatter(df['Name of States / UT'],df['Confirmed cases'])
<matplotlib.collections.PathCollection at 0x116958418d0>
df.iplot(kind='scatter',x='Name of States / UT',y='Confirmed cases',mode='markers+lines',title='Graphical representation',xTitle='Name of States / UT',yTitle='Confimed cases',colors='red',size=20)
px.scatter(df,x='Name of States / UT',y='Confirmed cases')
fig = go.Figure()
fig.add_trace(go.Bar(x=df['Name of States / UT'], y=df['Confirmed cases']))
fig.update_layout(title='Total Cases in India', xaxis=dict(title='Name of States / UT'),yaxis=dict(title='Confirmed cases'))